<%-- 
    Document   : selectedItems
    Created on : 23 Jun, 2011, 10:41:13 AM
    Author     : mpower
--%>
selectedItems.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List,shopping.Item"%>
    <script>
        function doRemove(itemCode) {
            var frm=document.rmItem;
            frm.itemCode.value=itemCode;
            frm.submit();
        }
    </script>
       <%
            List<Item> cart=(List<Item>)session.getAttribute("cart");
            if((!(cart==null))&&(!(cart.isEmpty()))) {
       %>
       <p align="center"><b>Items in Cart</b></p>
           <table border="1" align="center">
               <tr>
                   <th>Item Code</th>
                   <th>Item Name</th>
                   <th>Qty.</th>
                   <th>Price(Rs.)</th>
                   <th>Amount(Rs.)</th>
               </tr>
           <%
           double total=0.0;
           for(Item item:cart) {
               double amount=item.getPrice()*item.getQty();
               total+=amount;
               %>
               <tr>
                   <td><%=item.getItemCode()%></td>
                   <td><%=item.getItemName()%></td>
                   <td align="right"><%=item.getQty()%></td>
                   <td align="right"><%=item.getPrice()%></td>
                   <td align="right"><%=amount%></td>
                   <td><a href="javascript:void(0);" onclick="doRemove('<%=item.getItemCode()%>')">Remove</a></td>
               </tr>
                   <%
                   }
                   %>
                   <tr>
                       <td colspan="5" align="right">Total:Rs.<%=total%></td>
                   </tr>
                   </table>
                       <%
                       }
                       %>
                   <form name="rmItem" action="<%=application.getContextPath()%>/shopping" method="post">
                       <input type="hidden" name="command" value="removeItem"/>
                       <input type="hidden" name="itemCode" value=""/>
                   </form>
                  <form name="checkout" action="<%=application.getContextPath()%>/shopping" method="post">
                      <input type="hidden" name="command" value="checkout"/>
                      <input type="submit" value="Checkout"/>
                  </form>